package views.inventory;

import javax.swing.JPanel;
import javax.swing.SpringLayout;
import javax.swing.JLabel;
import javax.swing.JTextField;
import javax.swing.JButton;
import java.awt.Font;
import java.awt.event.ActionListener;

public class ManuallyStockUpdateView extends JPanel 
{
	private JTextField tfBarcode;
	private JTextField tfCategory;
	private JTextField tfMaterialCode;
	private JTextField tfMrp;
	private JTextField tfQuantity;
	private JButton btnIncrease;
	private JButton btnDecrease;
	private JButton btnUpdate;
	public ManuallyStockUpdateView() {
		SpringLayout springLayout = new SpringLayout();
		setLayout(springLayout);
		
		JLabel lblBarcode = new JLabel("Barcode");
		lblBarcode.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblBarcode, 20, SpringLayout.NORTH, this);
		springLayout.putConstraint(SpringLayout.WEST, lblBarcode, 20, SpringLayout.WEST, this);
		add(lblBarcode);
		
		tfBarcode = new JTextField();
		tfBarcode.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, tfBarcode, 6, SpringLayout.SOUTH, lblBarcode);
		springLayout.putConstraint(SpringLayout.WEST, tfBarcode, 0, SpringLayout.WEST, lblBarcode);
		add(tfBarcode);
		tfBarcode.setColumns(10);
		
		JLabel lblCategory = new JLabel("Category");
		lblCategory.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblCategory, 10, SpringLayout.SOUTH, tfBarcode);
		springLayout.putConstraint(SpringLayout.WEST, lblCategory, 0, SpringLayout.WEST, lblBarcode);
		add(lblCategory);
		
		tfCategory = new JTextField();
		tfCategory.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, tfCategory, 6, SpringLayout.SOUTH, lblCategory);
		springLayout.putConstraint(SpringLayout.WEST, tfCategory, 0, SpringLayout.WEST, lblBarcode);
		add(tfCategory);
		tfCategory.setColumns(10);
		
		JLabel lblMaterialCode = new JLabel("Material Code");
		lblMaterialCode.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblMaterialCode, 10, SpringLayout.SOUTH, tfCategory);
		springLayout.putConstraint(SpringLayout.WEST, lblMaterialCode, 0, SpringLayout.WEST, lblBarcode);
		add(lblMaterialCode);
		
		tfMaterialCode = new JTextField();
		tfMaterialCode.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, tfMaterialCode, 6, SpringLayout.SOUTH, lblMaterialCode);
		springLayout.putConstraint(SpringLayout.WEST, tfMaterialCode, 0, SpringLayout.WEST, lblBarcode);
		add(tfMaterialCode);
		tfMaterialCode.setColumns(10);
		
		JLabel lblMrp = new JLabel("MRP");
		lblMrp.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblMrp, 10, SpringLayout.SOUTH, tfMaterialCode);
		springLayout.putConstraint(SpringLayout.WEST, lblMrp, 0, SpringLayout.WEST, lblBarcode);
		add(lblMrp);
		
		tfMrp = new JTextField();
		tfMrp.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, tfMrp, 6, SpringLayout.SOUTH, lblMrp);
		springLayout.putConstraint(SpringLayout.WEST, tfMrp, 0, SpringLayout.WEST, lblBarcode);
		add(tfMrp);
		tfMrp.setColumns(10);
		
		JLabel lblQuntity = new JLabel("Quntity");
		lblQuntity.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, lblQuntity, 10, SpringLayout.SOUTH, tfMrp);
		springLayout.putConstraint(SpringLayout.WEST, lblQuntity, 0, SpringLayout.WEST, lblBarcode);
		add(lblQuntity);
		
		tfQuantity = new JTextField();
		tfQuantity.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 12));
		springLayout.putConstraint(SpringLayout.NORTH, tfQuantity, 6, SpringLayout.SOUTH, lblQuntity);
		springLayout.putConstraint(SpringLayout.WEST, tfQuantity, 0, SpringLayout.WEST, lblBarcode);
		add(tfQuantity);
		tfQuantity.setColumns(10);
		
		btnIncrease = new JButton("+");
		btnIncrease.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, btnIncrease, 0, SpringLayout.NORTH, tfQuantity);
		springLayout.putConstraint(SpringLayout.WEST, btnIncrease, 6, SpringLayout.EAST, tfQuantity);
		add(btnIncrease);
		btnIncrease.setActionCommand("increase");
		
		btnDecrease = new JButton("-");
		btnDecrease.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, btnDecrease, 0, SpringLayout.NORTH, tfQuantity);
		springLayout.putConstraint(SpringLayout.WEST, btnDecrease, 6, SpringLayout.EAST, btnIncrease);
		add(btnDecrease);
		btnDecrease.setActionCommand("decrease");
		
		btnUpdate = new JButton("Update");
		btnUpdate.setFont(new Font("MS Reference Sans Serif", Font.PLAIN, 13));
		springLayout.putConstraint(SpringLayout.NORTH, btnUpdate, 10, SpringLayout.SOUTH, tfQuantity);
		springLayout.putConstraint(SpringLayout.WEST, btnUpdate, 0, SpringLayout.WEST, lblBarcode);
		add(btnUpdate);
		btnUpdate.setActionCommand("update");
	}
	
	public void addActionListenerOnButtons(ActionListener al)
	{
		btnUpdate.addActionListener(al);
		btnIncrease.addActionListener(al);
		btnDecrease.addActionListener(al);
	}

	public JTextField getTfBarcode() {
		return tfBarcode;
	}

	public void setTfBarcode(JTextField tfBarcode) {
		this.tfBarcode = tfBarcode;
	}

	public JTextField getTfCategory() {
		return tfCategory;
	}

	public void setTfCategory(JTextField tfCategory) {
		this.tfCategory = tfCategory;
	}

	public JTextField getTfMaterialCode() {
		return tfMaterialCode;
	}

	public void setTfMaterialCode(JTextField tfMaterialCode) {
		this.tfMaterialCode = tfMaterialCode;
	}

	public JTextField getTfMrp() {
		return tfMrp;
	}

	public void setTfMrp(JTextField tfMrp) {
		this.tfMrp = tfMrp;
	}

	public JTextField getTfQuantity() {
		return tfQuantity;
	}

	public void setTfQuantity(JTextField tfQuantity) {
		this.tfQuantity = tfQuantity;
	}

	public JButton getBtnIncrease() {
		return btnIncrease;
	}

	public void setBtnIncrease(JButton btnIncrease) {
		this.btnIncrease = btnIncrease;
	}

	public JButton getBtnDecrease() {
		return btnDecrease;
	}

	public void setBtnDecrease(JButton btnDecrease) {
		this.btnDecrease = btnDecrease;
	}

	public JButton getBtnUpdate() {
		return btnUpdate;
	}

	public void setBtnUpdate(JButton btnUpdate) {
		this.btnUpdate = btnUpdate;
	}
	
	
}
